﻿<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		

		<title>首次登录 修改密码</title>

		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
		<script language=javascript>  
			//判断输入密码的类型  
			//测试某个字符是属于哪一类.  
			function CharMode(iN){  
			if (iN>=48 && iN <=57) //数字  
			return 1;  
			if (iN>=65 && iN <=90) //大写  
			return 2;  
			if (iN>=97 && iN <=122) //小写  
			return 4;  
			else  
			return 8;   //特殊字符  
			}  
			//bitTotal函数  
			//计算出当前密码当中一共有多少种模式  
			function bitTotal(num){  
			modes=0;  
			for (i=0;i<4;i++){  
			if (num & 1) modes++;  
			num>>>=1;  
			}  
			return modes;  
			}  
			//返回强度级别  
			function checkStrong(sPW){  
			if (sPW.length<8)  
			return 0; //密码太短  
			Modes=0;  
			for (i=0;i<sPW.length;i++){  
			//测试每一个字符的类别并统计一共有多少种模式.  
			Modes|=CharMode(sPW.charCodeAt(i));  
			}  
			return bitTotal(Modes);  
			}  
			var S_level;
			//显示颜色  
			function pwStrength(pwd){  
			O_color="#eeeeee";  
			L_color="#FF0000";  
			M_color="#FF9900";  
			H_color="#33CC00";  
			if (pwd==null||pwd==''){  
			Lcolor=Mcolor=Hcolor=O_color;  
			}  
			else{  
			S_level=checkStrong(pwd);  
			switch(S_level) {  
			case 0:  
			Lcolor=Mcolor=Hcolor=O_color;  
			case 1:  
			Lcolor=L_color;  
			Mcolor=Hcolor=O_color;  
			break;  
			case 2:  
			Lcolor=Mcolor=M_color;  
			Hcolor=O_color;  
			break;  
			default:  
			Lcolor=Mcolor=Hcolor=H_color;  
			}  
			}  
			document.getElementById("strength_L").style.background=Lcolor;  
			document.getElementById("strength_M").style.background=Mcolor;  
			document.getElementById("strength_H").style.background=Hcolor;  
			return;  
			}  
			
			function sub(){
				var newPwd=document.getElementById("newPwd").value;
				var newPwd2=document.getElementById("newPwd2").value;
//				if(newPwd.length<7){
//					alert("新密码不得小于8位！");
//				}
				if(S_level<2){
					alert("密码强度不够！");
				}else{
					if(newPwd != newPwd2){
						alert("两次输入密码不一致！");
					}else{
						document.changePwd.submit();
					}
				}
			}
			
			
</script>

	    <style type="text/css">
<!--
.STYLE1 {
	font-size: 16px;
	color: #0000FF;
}
-->
        </style>
</head>

	<body style="font-size: 12px; background:#ebf2f8; text-align:center;">

		<p>
		  <%
		//	String message=(String)request.getParameter("message");	
        //    if(message!=null){
        //        String str=new String(message.getBytes("8859_1"),"GB2312"); 
        //        out.println(str);
        //    }
        	String message=(String)request.getAttribute("message");
			String serverUrl=(String)request.getAttribute("serverUrl");
        	String html="<font color='red' style='font-size: 12px'>"+message+"</font><br>";
        	if(message!=null){
        		out.println(html);
        	}
		 %>
    </p>
		<form name="changePwd" method="post" action="<%=path%>/fristChangePwd.do">
			<table border="1" cellpadding="1" cellspacing="0" bordercolor="#9966FF"  style="font-size: 12px; margin-top: 240px; background:#ebf2f8; border-collapse: collapse; width:30%;">
			<tr>
				<td colspan="2"><div align="center" class="STYLE1">首次登录请修改密码</div></td>
			  </tr>
				<tr>
					<td width="39%">
						<div align="right">旧密码：					</div></td>
					<input type='hidden' name='serverUrl' value='<%=serverUrl%>'>
					<td width="61%">
						<div align="left">
						  <input type="password" name="oldPwd">
				        </div></td>
				</tr>
				<tr>
					<td colspan="2">
						<div align="center">注意：新密码长度不得小于8位，
					且至少使用2种不同类型字符<br>（如：大小写字母加数字）！                    </div></td>
				</tr>
				<tr>
					<td>
					<div align="right">新密码：				    </div></td>
					<td>
						<div align="left">
						  <input id="newPwd" type="password" name="newPwd"
							onKeyUp=pwStrength(this.value) onBlur=pwStrength(this.value)>
				        </div></td>
				</tr>
				<tr>
					<td>
					<div align="right">密码强度：				    </div></td>
					<td>
						<table width="145" border="1" cellspacing="0" cellpadding="1"
							bordercolor="#eeeeee" height="22" style='display: inline;font-size: 12px'>
							<tr align="center" bgcolor="#f5f5f5">
								<td width="33%" id="strength_L">
									弱								</td>
								<td width="33%" id="strength_M">
									中								</td>
								<td width="33%" id="strength_H">
									强								</td>
							</tr>
						</table>
					    <div align="left"></div></td>
				</tr>
				<tr>
					<td>
					<div align="right">重复新密码：				    </div></td>
					<td>
						<div align="left">
						  <input id="newPwd2" type="password" name="newPwd2">
				        </div></td>
				</tr>
				<tr>
				<td colspan="2"> 
					  
			      <div align="center">
			        <input  value="修改" onClick="sub();"    type="button" name="enter" />
        			<a href="<%=basePath%>/help/mmxg.jsp" target="_blank">帮助</a>
		          </div></td>
				</tr>
		  </table>
		</form>
		
	</body>
</html>
